package com.zycfc.zsf.boot.druid;

import javax.sql.*;
import com.alibaba.druid.spring.boot.autoconfigure.*;
import com.alibaba.druid.pool.*;

public class ZsfDataSourceBuilder
{
    public static final int ZSF_DEFAULT_INITIAL_SIZE = 20;
    public static final int ZSF_DEFAULT_MAX_ACTIVE_SIZE = 50;
    
    public DataSource build() {
        final DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
        final int initialSize = dataSource.getInitialSize();
        if (initialSize < 20) {
            dataSource.setInitialSize(20);
        }
        final int maxActive = dataSource.getMaxActive();
        if (maxActive < 50) {
            dataSource.setMaxActive(50);
        }
        return (DataSource)dataSource;
    }
    
    public static ZsfDataSourceBuilder create() {
        return new ZsfDataSourceBuilder();
    }
}
